package game.VO
{
	import flash.utils.ByteArray;
	import game.manager.TemplateTileManager;
	
	/**
	 * ...
	 * @author Kirill Pletnev
	 */
	public class TileVO
	{
		public var tileTemplateID:int;
		public var columnPosition:int;
		public var rowPosition:int;
		
		public function TileVO(tileTemplateID:int, columnPosition:int, rowPosition:int)
		{
			this.tileTemplateID = tileTemplateID;
			this.columnPosition = columnPosition;
			this.rowPosition = rowPosition;
		}
		
		public function getTileTemplateVO(tileTemplateID:int):TileTemplateVO
		{
			return TemplateTileManager.instance.getTemplateTileById(tileTemplateID);
		}
		
		// SERIALIZATION ========================================================================
		public function serialize(data:ByteArray):void
		{
			data.writeInt(tileTemplateID);
			data.writeInt(columnPosition);
			data.writeInt(rowPosition);
		}
		
		public static function deserialize(data:ByteArray):TileVO
		{
			var tileTemplateID:int = data.readInt();
			var columnPosition:int = data.readInt();
			var rowPosition:int = data.readInt();
			
			return new TileVO(tileTemplateID, columnPosition, rowPosition);
		}
		
		public function toString():String
		{
			return "[TileVO tileTemplateID=" + tileTemplateID + " columnPosition=" + columnPosition + " rowPosition=" + rowPosition + "]";
		}
	}

}